package com.zut.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zut.dao.PractiseDao;
import com.zut.domain.Practise;
import com.zut.service.PractiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PractiseServiceImpl implements PractiseService {
    @Autowired
    private PractiseDao practiseDao;


    public PageInfo<Practise> getAll(Integer pageNum, Integer pageSize) {
        List<Practise> list;
        PageHelper.startPage(pageNum, pageSize);
        list = practiseDao.getAll();
        return new PageInfo<>(list);
    }

    public PageInfo<Practise> getTwo(Integer pageNum, Integer pageSize) {
        List<Practise> list;
        PageHelper.startPage(pageNum, pageSize);
        list = practiseDao.getTwo();
        return new PageInfo<>(list);
    }

    public PageInfo<Practise> getThree(Integer pageNum, Integer pageSize) {
        List<Practise> list;
        PageHelper.startPage(pageNum, pageSize);
        list = practiseDao.getThree();
        return new PageInfo<>(list);
    }

    public boolean insert(Practise practise) {
        return practiseDao.insert(practise) > 0;
    }

    public boolean deleteById(String id) {
        return practiseDao.deleteById(id) > 0;
    }

    public boolean update(Practise practise) {
        return practiseDao.update(practise) > 0;
    }

    public PageInfo<String> getPlace(Integer pageNum, Integer pageSize) {
        List<String> list;
        PageHelper.startPage(pageNum, pageSize);
        list = practiseDao.getPlace();
        return new PageInfo<>(list);
    }

    public PageInfo<Practise> getByPlace(Integer pageNum, Integer pageSize, String place) {
        List<Practise> list;
        PageHelper.startPage(pageNum, pageSize);
        list = practiseDao.getByPlace(place);
        return new PageInfo<>(list);
    }
}
